package com.fbty.mt.action.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fbty.base.action.BaseAction;
import com.fbty.mt.domain.Price;
import com.fbty.mt.domain.User;
import com.fbty.mt.service.PriceService;
import com.fbty.mt.utils.StaticValue;

public class PriceAction extends BaseAction {
	
	private List<Price> generalPrices = new ArrayList<Price>();
	
	private List<Price> monthPrices = new ArrayList<Price>();
	
	private List<Price> onlyPrices = new ArrayList<Price>();
	private String message;
	private PriceService priceService;
	//独享天数
	private String days;
	
	private String discountPrice;
	
	private static Map<String, String> discount = new HashMap<String, String>();
	static {
		discount.put("0.5", "100");
		discount.put("5", "85");
		discount.put("15", "75");
		discount.put("30", "50");
		discount.put("60", "40");
	}
	
	public String showPrice(){
		User user = (User) sessionMap.get("user");
		if(user == null) {
			message = "请先登陆系统!";
			return "login";
		}
		List<Price> list = priceService.queryPrices();
		for(Price p:list){
			switch (p.getType()) {
			case StaticValue.GENERAL:
				generalPrices.add(p);
				break;
			case StaticValue.MONTH:
				monthPrices.add(p);
				break;
			case StaticValue.ONLY:
				onlyPrices.add(p);
				break;
			}
		}
		
		return "success";
		
	}
	
	public List<Price> getGeneralPrices() {
		return generalPrices;
	}

	public List<Price> getMonthPrices() {
		return monthPrices;
	}

	public List<Price> getOnlyPrices() {
		return onlyPrices;
	}

	public void setPriceService(PriceService priceService) {
		this.priceService = priceService;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public String getDiscount(){
		
		discountPrice = discount.get(days);
		
		return "discount";
	}
	
	public void setDays(String days) {
		this.days = days;
	}
	
	public String getDays() {
		return days;
	}
	
	public void setDiscountPrice(String discountPrice) {
		this.discountPrice = discountPrice;
	}
	
	public String getDiscountPrice() {
		return discountPrice;
	}
	
}
